<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang='en'>
<head>
	<meta charset='utf-8' />
	<title>广溢信息技术有限公司</title>
	<meta content='' name='description' />
	<meta content='' name='author' />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<!-- Bootstrap -->
	<link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet" >
    <link href="__PUBLIC__/css/jquery-ui-1.9.2.custom.css" rel="stylesheet" />
	<link href="__PUBLIC__/css/font-awesome.min.css" rel="stylesheet" >

	<!--[if IE 7]>
		<link  href="__PUBLIC__/css/font-awesome-ie7.min.css" rel="stylesheet">
	<![endif]-->

	<!--[if lt IE 9]>
		<link type="text/css" href="__PUBLIC__/css/custom-theme/jquery.ui.1.9.2.ie.css"  rel="stylesheet" />
	<![endif]-->

	<link href="__PUBLIC__/css/bootstrap-responsive.css" rel="stylesheet">
	<link href="__PUBLIC__/css/test.css" rel="stylesheet">
	<script src="__PUBLIC__/js/jquery.js"></script>

	<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
	<!--[if lt IE 9]>
	<script src="__PUBLIC__/js/html5shiv.js"></script>
	<script src="__PUBLIC__/js/respond.min.js"></script>
	<![endif]-->
	<script type="text/javascript">
	var upload_url="<?php echo U('file/upload?module='.MODULE_NAME);?>";
	var del_url="<?php echo U('File/del');?>";
	var session_id="<?php echo session_id();?>";	
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "//hm.baidu.com/hm.js?2a935166b0c9b73fef3c8bae58b95fe4";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
</script>
</head>
<body>
	<div class="shade"></div>
	<div class="row-fluid navbar visible-phone">
	<div class="row-fluid">
		<a class="brand" href="<?php echo U('home/index');?>">广溢网络</a>
		<a data-toggle="collapse" data-target="#top_menu" class="right">
		<i class="brand icon-th-list"></i>
		</a>
	</div>
	<div class="col-lapse" id="top_menu">
		<ul class="nav nav-pills">
			<?php if(is_array($list_top_menu)): $i = 0; $__LIST__ = $list_top_menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$tag): $mod = ($i % 6 );++$i;?><li>
					<a  href="#" url="<?php echo U($tag['url']);?>" node="<?php echo ($tag["id"]); ?>" onclick="click_top_menu(this)"><?php echo ($tag["name"]); ?></a>
				</li><?php endforeach; endif; else: echo "" ;endif; ?>
		</ul>
	</div>
</div>
<div class="row-fluid navbar hidden-phone">
	<a class="brand" href="<?php echo U('home/index');?>">广溢网络</a>
	<ul class="nav nav-pills">
		<?php if(is_array($list_top_menu)): $i = 0; $__LIST__ = $list_top_menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$tag): $mod = ($i % 6 );++$i;?><li>
				<a  href="#" url="<?php echo U($tag['url']);?>" node="<?php echo ($tag["id"]); ?>" onclick="click_top_menu(this)"><?php echo ($tag["name"]); ?></a>
			</li><?php endforeach; endif; else: echo "" ;endif; ?>
	</ul>
	<aside>
		<span>
			<a href="<?php echo U('UserConfig/index');?>">设置</a>
		</span>
		<span>
			<a href="<?php echo U('profile/index');?>"><?php echo (session('user_name')); ?></a>
		</span>
		<span>
			<a href="<?php echo U('login/logout');?>">退出</a>
		</span>
		&nbsp;&nbsp;
	</aside>
</div>

	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span3 left_menu">
				<div class="visible-phone">
	<h4 class="btn no-border" data-toggle="collapse" data-target="#left_menu">		
			<?php echo ($top_menu_name); ?><i class="icon-angle-down"></i>
		</h4>
	<div class="col-lapse" id="left_menu"><?php echo ($html_left_menu); ?></div>
</div>
<div class="hidden-phone">
	<h4><?php echo ($top_menu_name); ?></h4>
	<div><?php echo ($html_left_menu); ?></div>
</div>
			</div>
			<div class="span9 content">
<script type="text/javascript">
	function test() {
		form_search.submit();
	};

	function save() {
		$("#node_list").val('');
		$(".sub_left_menu .tree_menu input[name='node_id']:checked").each(function() {
			$("#node_list").val($("#node_list").val() + $(this).val() + ",");
		})
		sendForm("form_data", "<?php echo U('set_node');?>");
	};

	function showdata(result){
		$(".sub_left_menu .tree_menu input").each(function(){
			$(this).attr("checked", false);
			$(this).parents("td").removeClass("active");
		});
		for (var s in result.data){
			$(".sub_left_menu .tree_menu input[name='node_id'][value=" + result.data[s].node_id + "]").attr("checked", true);

			if(result.data[s].admin==1){
				$(".sub_left_menu .tree_menu input[name='admin[]'][value=" + result.data[s].node_id + "]").attr("checked", true);			
				$(".sub_left_menu .tree_menu input[name='admin[]'][value=" + result.data[s].node_id + "]").parents("td").addClass("active");
			}
			if(result.data[s].write==1){
				$(".sub_left_menu .tree_menu input[name='write[]'][value=" + result.data[s].node_id + "]").attr("checked", true);
				$(".sub_left_menu .tree_menu input[name='write[]'][value=" + result.data[s].node_id + "]").parents("td").addClass("active");						
			}
			if(result.data[s].read==1){
				$(".sub_left_menu .tree_menu input[name='read[]'][value=" + result.data[s].node_id + "]").attr("checked", true);
				$(".sub_left_menu .tree_menu input[name='read[]'][value=" + result.data[s].node_id + "]").parents("td").addClass("active");							
			}
			$(".sub_left_menu .tree_menu input[node=" + result.data[s].node_id + "]").parents("td").addClass("active");
		};
		$("#org_node_list").val('');
		$(".sub_left_menu .tree_menu input[name='node_id']:checked").each(function() {;
			$("#org_node_list").val($("#org_node_list").val() + $(this).val() + ",");
		})
		$("#opmode").val("edit");
	};

	$(document).ready(function() {
		set_return_url();
		$(".role_list  tr").click(function() {
			$(".role_list  tr").attr("class","");
			$(this).attr("class","active");
			$("#role_id").val($(this).attr("id"));
			sendAjax("<?php echo U('get_node_list');?>", "role_id=" + $(this).attr("id"), function(data) {
				showdata(data);
			});
			return false;
		})

		$(".sub_left_menu .tree_menu input").click(function(event) {	
			if ($(this).attr("checked") == "checked") {
				$(this).parents("td").addClass("active");
			} else {
				$(this).parents("td").removeClass("active");				
			}
			event.stopPropagation();
		})


		$(".sub_left_menu .tree_menu  td").click(function() {
			if ($(this).find("input").attr("checked") == "checked") {
				$(this).find("input").attr("checked", false);
				$(this).removeClass("active");
			} else {
				if($(this).find("input").length>0){
					$(this).find("input").attr("checked", true);
					$(this).addClass("active");
				}
			}
		})
	}); 
</script>
<div class="admin" >
	<div class="row-fluid title">
		<span>权限组管理</span>
	</div>
	<form name="form_search" method="post" action="">
		<div class=" row-fluid operate" >
			<div class="left">
				<select type="select-one" id="" name="s_pid" onchange="test()" ondblclick="" class="" ><?php  foreach($groupList as $key=>$val) { if(!empty($pid) && ($pid == $key || in_array($key,$pid))) { ?><option selected="selected" value="<?php echo $key ?>"><?php echo $val ?></option><?php }else { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } } ?></select>
			</div>
			<div class="right">
				<a onclick="save()" class="btn">保存</a>
			</div>
		</div>
	</form>
	<div class="row-fluid">
		<div class="span4 role_list">
			<table class="table table-bordered">
				<tr>
					<th>名称</th>
				</tr>
				<?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><tr id="<?php echo ($data["id"]); ?>">
						<td><?php echo ($data["name"]); ?></td>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
			</table>
		</div>
		<div class="span8 sub_left_menu">
			<form id="form_data" method="post" action="">
				<input type="hidden" name="ajax" id="ajax" value="1">
				<input type="hidden" name="role_id" id="role_id">
				<input type="hidden" name="org_node_list" id="org_node_list">
				<input type="hidden" name="node_list" id="node_list">
				<div class="wrap tree_menu">
					<table class="table table-bordered">
						<tr>
							<th style="width:55%;text-align:center">菜单</th>
							<th style="width:15%;text-align:center">读取</th>
							<th style="width:15%;text-align:center">写入/修改</th>
							<th style="width:15%;text-align:center">管理</th>
						</tr>
						<?php if(is_array($node_list)): $i = 0; $__LIST__ = $node_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><tr >
								<td>
									<i class="icon level<?php echo ($data['level']+1); ?>"></i>
									<input node="<?php echo ($data["id"]); ?>" type="checkbox" name="node_id" value="<?php echo ($data["id"]); ?>"><?php echo ($data["name"]); ?></td>
								<?php if(strpos($data['url'],'/index')): ?><td style="text-align:center">
										<input type="checkbox" name="read[]" value="<?php echo ($data["id"]); ?>"></td>
									<td  style="text-align:center">
										<input type="checkbox" name="write[]" value="<?php echo ($data["id"]); ?>"></td>
									<td  style="text-align:center">
										<input type="checkbox" name="admin[]" value="<?php echo ($data["id"]); ?>"></td>
									<?php else: ?>
									<td class="check_box text-center">&nbsp;</td>
									<td class="check_box text-center">&nbsp;</td>
									<td class="check_box text-center">&nbsp;</td><?php endif; ?>
							</tr><?php endforeach; endif; else: echo "" ;endif; ?>
					</table>
				</div>
			</form>
		</div>
	</div>
</div></div>
		</div>
	</div>
	<div class="msg popout"></div>
	<iframe src="<?php echo U('push/client');?>" class="push" id="push"></iframe>
	<script src="__PUBLIC__/js/bootstrap.min.js"></script>
	<script src="__PUBLIC__/js/jquery-ui-1.9.2.custom.min.js"></script>
	<script src="__PUBLIC__/js/common.js"></script>
</body>
</html>